package com.example.smartcity_poverty.ui.SmartSubject.Adapter

import androidx.annotation.LayoutRes
import com.example.smartcity_poverty.App
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.logic.util.Util
import com.example.smartcity_poverty.ui.SmartSubject.bean.SubjectHomeRvItemBean
import kotlinx.android.synthetic.main.re_subject_item.*

/**
 *  ANDROID STUDIO -VERSION 4.0
 *  email: 2506789532@qq.com
 *  CodeAuthor： Ikun
 *
 *  explain: 限选主页列表适配器
 *  @param list 数据源
 *  @param layoutId 布局ID
 **/
class SubjectHomeRvAdapter(
    val list: MutableList<SubjectHomeRvItemBean>,
    @LayoutRes
    val layoutId: Int
) : BaseRecyclerAdapter<SubjectHomeRvItemBean>(list, layoutId) {
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: SubjectHomeRvItemBean,
        position: Int,
        holder: BaseViewHolder
    ) {
        // 设置动画
        holder.itemView.animation = App.getAnimationBottomAndTop()

        // 填充数据
        val resultData = list[position].apply {
            // 图片
            view.SubjectItemImg.setImageResource(this.setSubjectItemImg)
            // 标题
            view.SubjectItemTitle.text = this.setSubjectItemTitle
        }

        // 点击事件
        holder.itemView.setOnClickListener {
            // 跳转到指定的Activity
            Util.startActivityUtils(holder.itemView.context, resultData.setSubjectItemActivity)
        }
    }
}